package china.accountinghelper.adapter;

import java.util.ArrayList;
import java.util.List;

import china.wc.tallyhelper.R;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

public class AdapterViewPagerWelcom extends PagerAdapter
{
    private Context mContext;
    private List<ImageView> mImageViews;
    
    public AdapterViewPagerWelcom(Context pContext)
    {
        mContext = pContext;
        mImageViews = new ArrayList<ImageView>();
        int[] Images = {
                R.drawable.welcom1,
                R.drawable.welcom2,
                R.drawable.welcom3,
                R.drawable.welcom4,
                R.drawable.welcom5,
        };
        
        for (int _Res : Images) {
            ImageView _ImageView = new ImageView(mContext);
            ViewGroup.LayoutParams _LayoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            _ImageView.setImageResource(_Res);
            _ImageView.setLayoutParams(_LayoutParams);
            mImageViews.add(_ImageView);
        }
        
    }

    @Override
    public int getCount()
    {
        return mImageViews.size();
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position)
    {
        container.addView(mImageViews.get(position));
        return mImageViews.get(position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object)
    {
        container.removeView(mImageViews.get(position));
    }

    @Override
    public boolean isViewFromObject(View view, Object object)
    {
        return view == object;
    }


}
